//控制Layer，其实是菜单

//run Once, like : onAttackEnemyClick()
var control = {
	menuBackMenu : null,
	warInfoMenu : null,
	battleReviewMenu : null,
	deployMenu : null,
	debugMenu : null,
	
	onMenuBackClick : null,
	onWarInfoClick : null,
	onBattleReviewClick : null,
	onDeployedClick : null,
	onDebugClick : null
};

var ControlLayer = cc.Layer.extend({
	
	ctor: function () {
		this._super();
		
		var winSize = cc.director.getWinSize();
		
		control.menuBackMenu = this._CreateMenuButton(		114 * 1, winSize.height - 21, "≡", control.onMenuBackClick);
		control.warInfoMenu = this._CreateMenuButton(		114 * 2, winSize.height - 21, "情报", control.onWarInfoClick);
		control.battleReviewMenu = this._CreateMenuButton(	114 * 3, winSize.height - 21, "战报", control.onBattleReviewClick);
		control.deployMenu = this._CreateMenuButton(		114 * 4, winSize.height - 21, "开战", control.onDeployedClick);
		control.debugMenu = this._CreateMenuButton(		114 * 5, winSize.height - 21, "调试", control.onDebugClick);
		
		var menu = cc.Menu.create(
			control.menuBackMenu,
			control.warInfoMenu,
			control.battleReviewMenu,
			control.deployMenu,
			control.debugMenu
		);
		menu.attr({x: 0, y: 0});
		this.addChild(menu);
	},
	
	_CreateMenuButton : function(xpos,ypos,text,callback){
		var button = new cc.MenuItemImage(resource.menubtnNormal_png,resource.menubtnDown_png, resource.menubtnDisable_png, callback, this);
		button.attr({x: xpos, y: ypos});
		var label = cc.LabelTTF.create(text, "simhei", 28);
		label.attr({x: button.width * 0.5, y: button.height * 0.5});
		label.setColor(cc.color(0,0,0));
		button.addChild(label);
		return button;
	}
});